package servlet;

import javax.servlet.annotation.WebServlet;
import java.io.IOException;
import java.io.PrintWriter;

//访问的路径
//输出html
//@javax.servlet.annotation.WebServlet(name = "HelloServlet",value = "/hello")
@WebServlet("/hello")
public class HelloServlet extends javax.servlet.http.HttpServlet {

    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        request.getParameter("sss");
        request.getParameterValues("ss");//数组

        response.setContentType("text/html;charset=utf-8");//中文乱码问题解决
        PrintWriter out = response.getWriter();
        out.print("<html>");
        out.print("<body>");
        out.print("<h1>");
        out.print("大家好，这是一个serlvet,这是一个post请求");
        out.print("</h>");
        out.print("</body>");
        out.print("</html>");
    }
    //这两个参数是容器提供！
    //request代表请求，response代表响应
    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");//中文乱码问题解决
        PrintWriter out = response.getWriter();
        out.print("<html>");
        out.print("<body>");
        out.print("<h1>");
        out.print("大家好，这是一个serlvet,这是一个get请求");
        out.print("</h>");
        out.print("</body>");
        out.print("</html>");

    }
}
